package com.xxg.renrenlogin.domain.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 通过返回结果类型
 *
 * @author xxg
 * @date 2020-09-25
 */
@Data
@AllArgsConstructor
@ApiModel(value = "BaseResult", description = "结果信息")
public class BaseResult {
    @ApiModelProperty(value = "结果代码，200-正常，非200-异常")
    private Integer code;
    @ApiModelProperty(value = "调用返回信息")
    private String message;
    @ApiModelProperty(value = "异常信息")
    private String errorMessage;
    @ApiModelProperty(value = "结果信息")
    private Object data;

    public BaseResult(Object data) {
        this.code = 200;
        this.message = "";
        this.errorMessage = "";
        this.data = data;
    }

    public BaseResult(LoginReturnCodeEnum codeEnum, String errorMessage, Object data) {
        this.code = codeEnum.getCode();
        this.message = codeEnum.getName();
        this.errorMessage = errorMessage;
        this.data = data;
    }
}
